#ifndef _BBOXPROCESSOR_H
#define _BBOXPROCESSOR_H

#include <iostream>
#include <string>
#include <cstdint>
#include <vector>
#include <algorithm>
#include "module_base/util.h"
#include "cuda_base/cuda_base.h"
#include "obstacle_detector/util.h"
#include "obstacle_detector/bbox_util.h"
#include "obstacle_detector/debug_display.h"
#include "obstacle_detector/convex_hull.h"

namespace obstacle_detector
{
class BBoxPorcessor
{
public:
	BBoxPorcessor(bool debug);
	~BBoxPorcessor(){};
	void bbox_process(const module_base::Location &loc,
		int16_t *points,int &point_num,std::vector<Object> &all_objects,
		std::vector<Object> &lst_objects,uint8_t *point_road_index, 
		int roads_num);
private:
	void bbox_compare(std::vector<Object> &all_objects,
		std::vector<Object> &lst_objects);
	void get_optional_velocity(const std::vector<Object> &all_objects,
		const std::vector<Object> &lst_objects,
		const std::vector<std::vector<int>> &matches,
		float *objects_velocity);
	


private:
	const float check_range[4]={-50,80,-50,50};
	const float resolution_=0.1;
	const int option_v_num_=7;
	int grid_dim_[2];

	bool debug_;

	module_base::Location lst_loc_;

	float objects_velocity_[1000*24];

	uint8_t *inbbox_order_gpu_; //点云的order在哪个bbox里面
	uint8_t *point_bbox_index_gpu_; //每个点在哪个框里
	uint8_t *occupancy_grid_gpu_;
	int *object_road_point_count_gpu_; //每个物体的点落在不同车道的数量，以及点的总数

	uint8_t *lst_related_gpu_;
	uint8_t *objects_related_gpu_;
	float *objects_velocity_gpu_;
	int *velocity_score_gpu_;
	float *region_data_gpu_;
	// bool *eliminated_order_gpu_;
	
	// int16_t *valid_points_gpu_;
	// int *valid_points_num_gpu_;
	// uint16_t *valid_points_order_gpu_;

	std::unique_ptr<DebugDisplay> debug_display_;
	std::unique_ptr<ConvexHull> convex_hull_;

};//class
}

#endif 